package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormDiskOutDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormDiskOutDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormDiskOutDetailConverter {

    public static FlowFormDiskOutDetailDto do2Dto(FlowFormDiskOutDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        FlowFormDiskOutDetailDto dto = FlowFormDiskOutDetailMapper.INSTANCE.do2Dto(domain);
        return dto;
    }

    public static List<FlowFormDiskOutDetailDto> do2Dto(List<FlowFormDiskOutDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormDiskOutDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormDiskOutDetail dto2Do(FlowFormDiskOutDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        FlowFormDiskOutDetail domain = FlowFormDiskOutDetailMapper.INSTANCE.dto2Do(dto);
        return domain;
    }

    public static List<FlowFormDiskOutDetail> dto2Do(List<FlowFormDiskOutDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormDiskOutDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormDiskOutDetailMapper {

        FlowFormDiskOutDetailMapper INSTANCE = Mappers.getMapper(FlowFormDiskOutDetailMapper.class);

        FlowFormDiskOutDetailDto do2Dto(FlowFormDiskOutDetail domain);

        List<FlowFormDiskOutDetailDto> do2Dto(List<FlowFormDiskOutDetail> domain);

        FlowFormDiskOutDetail dto2Do(FlowFormDiskOutDetailDto dto);

        List<FlowFormDiskOutDetail> dto2Do(List<FlowFormDiskOutDetailDto> dto);
    }
}
